<?php

use App\Http\Enums\HttpResCode;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;

if (!function_exists('success')) {
    function success(string $msg = '', array $data = []): JsonResponse
    {
        return new JsonResponse(['code' => HttpResCode::Success, 'msg' => $msg, 'data' => $data], '200');
    }
}


if (!function_exists('cLog')) {
    /**
     * @param $message
     * @param array $context
     */
    function cLog($message, array $context = [])
    {
        Log::channel('cron-daily')->info($message, $context);
    }
}

if (!function_exists('dbLog')) {
    /**
     * @param $message
     * @param array $context
     */
    function dbLog($message, array $context = [])
    {
        Log::channel('db-daily')->info($message, $context);
    }
}
